<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="../../../attr.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<!doctype html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8">
<link rel="stylesheet" href="${ctx}/css/sapar.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/css/common.css" />
<script type="text/javascript" src="${ctx}/js/jquery.js"></script>
<script type="text/javascript" src="${ctx}/js/sapar.js"></script>
<script type="text/javascript" src="${ctx}/js/WdatePicker.js"></script>
<script type="text/javascript" src="${ctx}/assets/layer/layer.js"></script>
<script type="text/javascript" src="${ctx}/js/kkpager.min.js"></script>
<link rel="stylesheet" type="text/css" href="${ctx}/css/kkpager_blue.css" />


<title>借物申请</title>
<style  type="text/css">
	#left{
		float:left; width:100%;
	}
	#saper-container{float:left;width:100%;background: url() repeat-y 99% 0;}
	#table_left{float:left; width:98%;min-height:300px}
	/* #right{
		float:right; width:30%;min-height:300px
	}  */
	.search-box .iselect-wrapper{
		float: left;
		margin-right: 5px;
		width: 150px;
	}
	
	.search-box .iselect-wrapper .iselect{
		width:150px;
	}
	#weifa{
	color:red;
	font-weight: bold;
	}
	#yifa{
	color:green;
	font-weight: bold;
	}
	th{
	text-align: center;
	}
	td{
	text-align: center;
	}
</style>
</head>

<body>
<div id="left">
	<div id="saper-container">
        <div id="saper-hd"></div>
        <div id="saper-bd">
            <div class="subfiled clearfix">
                <h2>借物申请</h2>
            </div>
            <div class="subfiled-content">
                <div class="search-box clearfix">              	
                    <div class="kv-item clearfix">
                    	<label>选择科室：</label>
                        <select name="wenjuanKeshi" onchange="signPro('0')">
               				<option value="">请选择</option>
               				<c:if test="${keshilist != null}">
	                           	<c:forEach items="${keshilist}" var="pro">
		                           	<c:if test="${pro.departmentId != 15}">
		                                <option value="${pro.departmentId}">${pro.departmentName}</option>
		                            </c:if>
	                            </c:forEach>		                                
                            </c:if>			                                
                         </select>
                    </div>
                    <a href="javascript:;" class="sapar-btn sapar-btn-recom query-btn" id="chaxun">查询</a>
                    <a style="margin-left: 200px;" href="javascript:;" class="sapar-btn sapar-btn-recom query-btn" id="shiyong">一次品使用</a>
                </div>

                <!--表格开始-->
                <div id="table_left" class="table">
                    <!--表格操作-->
                    <div class="table-operate ue-clear">
                        <a href="javascript:;" class="add">新增</a>
						<a href="javascript:;" class="edit">修改</a>
                    </div>
                    <!--表格具体内容-->
                    <div class="table-box">
						<table>
							<thead>
								<tr>
									<th><input type="checkbox" id="checkall" name="checkall"/></th>
									<th>科室名</th>
									<th>产品编号</th>
									<th>产品名称</th>
									<th>现有数量</th>
									<th>新增数量</th>
									<th>丢失数量</th>
									<th>最新操作时间</th>
								</tr>
							</thead>
							<tbody>
								<c:if test="${keshikucun != null}">
									<c:forEach items="${keshikucun }" var="kucun">
										<tr data="${kucun.kucunId}" class="kucundata">
											<td><input type="checkbox" name="key" value="${kucun.kucunId}"/></td>
											<td>${kucun.department.departmentName}</td>
											<td>${kucun.mubanId}</td>
											<td>
											    <c:if test="${kucun.kucunSort == 1 }">${kucun.packageMuban.packageName}</c:if>
											    <c:if test="${kucun.kucunSort == 2 }">${kucun.yicipinKucun.productName}</c:if>
											</td>
											<td>
												<c:if test="${kucun.yiyouKucun != null}">${kucun.yiyouKucun }</c:if>
												<c:if test="${kucun.yiyouKucun == null}">0</c:if>
											</td>
											<td>
												<c:if test="${kucun.xinzengKucun != null}">${kucun.xinzengKucun}</c:if>
												<c:if test="${kucun.xinzengKucun == null}">0</c:if>
											</td>
											<td>
												<c:if test="${kucun.diushiKucun != null}">${kucun.diushiKucun}</c:if>
												<c:if test="${kucun.diushiKucun == null}">0</c:if>
											</td>
											<td><fmt:formatDate value="${kucun.recordTime}"
													type="date" pattern="yyyy-MM-dd HH:mm:ss" /></td>
										</tr>
									</c:forEach>
								</c:if>
							</tbody>
						</table>
					</div>
					<div id="kkpager"></div>
                </div><!--表格结束-->
            
<!--表格开始-->
<%-- <div id="right">
   <div class="table">
	<div class="table-box">
						 <div class="table-operate ue-clear">
                    	 	<a href="javascript:;" class="view">查看</a> 
                    	 </div>
                    	 这个是右边显示的信息
                        <table id="detail">
                            <thead>
                                <tr>
                                    <th>包名称</th>
                                    <th>产品数量</th>
                                    <th>发放状态</th>
                                </tr>
                            </thead>
                            <tbody>
                                 
                            </tbody>
                        </table>
                    </div>
                    <div>
						<input id="leftPage" class="butLeft" type="button" value="上一页" />
						<input id="rightPage" class="butRight" type="button" value="下一页" />
						<span>到第&nbsp;</span><input id="goPage" class="textBox" type="text" value="1" /><span style="margin-left: 4px;">页&nbsp;</span>
						<input  id="sureBut" class="sure" type="button" value="确定" />
						<span>共</span><span class="totalPages" id="totalNum">0</span><span>&nbsp;页</span>
					</div>
                    </div> 
</div> --%>
            </div>
        </div>
        <div id="saper-ft"></div>
    </div>

   </div> 
<script type="text/javascript">
var pageSize = 10 , currentPage = 1 , totalPage;
var data = [];
	$(function(){
		var totalPage = ${total};
		var pageNo = getParameter('pageIndex');
		if(!pageNo){
			pageNo = 1;
		}
		//生成分页
		//有些参数是可选的，比如lang，若不传有默认值
		kkpager.generPageHtml({
			pno : pageNo,
			//总页码
			total : totalPage,
			//链接前部
			hrefFormer : '${ctx}/shoushubao/shoushubaoList',
			//链接尾部
			hrefLatter : '.do',
			getLink : function(n){
				return this.hrefFormer + this.hrefLatter + "?pageIndex="+n+"&searchTxt="+$('select option:selected').val();
			}
		});
		
		$("#chaxun").click(function(){
			window.location.href="${ctx}/keshikucun/keshikucunList.do?searchTxt="+$('select option:selected').val();
		});
		
		$("#shiyong").click(function(){
			window.location.href="${ctx}/keshikucun/yicipin.do";
		});
		
		$(".add").click(function(){
			window.location.href="${ctx}/keshikucun/caichanApplyEdit.do";
		});
		$("#checkall").click(function(){
   		   if(this.checked){
   		        $("input[name='key']").prop('checked', true);
   		    }else{
   		        $("input[name='key']").prop('checked', false);
   		    }
		}); 
		
		$(".edit").click(function(){
			var btn = true;
			var chk = getSelRecord();
			if(chk.length != 1){
				layer.msg("请选择一条数据！");
				btn = false;
			}
			var id = chk[0];
			if(btn){
				window.location.href="${ctx}/keshikucun/keshikucunEdit.do?id="+id;
			}
		});
		
	});
	<%--点击数据前面的选择框后面出结果 --%>
	function getSelRecord(){
		var chk_value =[];
		$('input[name="key"]:checked').each(function(){
			chk_value.push($(this).val()); 
		});
		return chk_value;
	}  
	
  	function getParameter(name) { 
		var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); 
		var r = window.location.search.substr(1).match(reg); 
		if (r!=null) return unescape(r[2]); return null;
  	}
</script>  
</body>
</html>